package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TimeText;
import com.ruoyi.system.service.ITimeTextService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 时间Controller
 * 
 * @author ruoyi
 * @date 2023-11-15
 */
@RestController
@RequestMapping("/system/text")
public class TimeTextController extends BaseController
{
    @Autowired
    private ITimeTextService timeTextService;

    /**
     * 查询时间列表
     */
    @PreAuthorize("@ss.hasPermi('system:text:list')")
    @GetMapping("/list")
    public TableDataInfo list(TimeText timeText)
    {
        startPage();
        List<TimeText> list = timeTextService.selectTimeTextList(timeText);
        return getDataTable(list);
    }

    /**
     * 导出时间列表
     */
    @PreAuthorize("@ss.hasPermi('system:text:export')")
    @Log(title = "时间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TimeText timeText)
    {
        List<TimeText> list = timeTextService.selectTimeTextList(timeText);
        ExcelUtil<TimeText> util = new ExcelUtil<TimeText>(TimeText.class);
        util.exportExcel(response, list, "时间数据");
    }

    /**
     * 获取时间详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:text:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(timeTextService.selectTimeTextById(id));
    }

    /**
     * 新增时间
     */
    @PreAuthorize("@ss.hasPermi('system:text:add')")
    @Log(title = "时间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TimeText timeText)
    {
        return toAjax(timeTextService.insertTimeText(timeText));
    }

    /**
     * 修改时间
     */
    @PreAuthorize("@ss.hasPermi('system:text:edit')")
    @Log(title = "时间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TimeText timeText)
    {
        return toAjax(timeTextService.updateTimeText(timeText));
    }

    /**
     * 删除时间
     */
    @PreAuthorize("@ss.hasPermi('system:text:remove')")
    @Log(title = "时间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(timeTextService.deleteTimeTextByIds(ids));
    }
}
